package com.dayaokeji.rhythmschoolstudent.client.common.ad;

import android.content.Context;

import com.dayaokeji.rhythmschoolstudent.client.common.base.AdConstant;
import com.orhanobut.logger.Logger;
import com.qq.e.ads.nativ.ADSize;
import com.qq.e.ads.nativ.NativeExpressAD;
import com.qq.e.ads.nativ.NativeExpressADView;
import com.qq.e.comm.util.AdError;

import java.util.List;

public class AdCallback implements NativeExpressAD.NativeExpressADListener
{

    private AdViewCallback adViewCallback;
    private Context context;

    public AdCallback(Context context, AdViewCallback adViewCallback){
        this.context = context;
        refreshAd();
        this.adViewCallback = adViewCallback;
    }
    private void refreshAd(){

        NativeExpressAD nativeExpressAD = new NativeExpressAD(context, new ADSize(340, ADSize.AUTO_HEIGHT), AdConstant.APPID, AdConstant.NativeExpressPosID, this);
        nativeExpressAD.loadAD(1);
    }
    @Override
    public void onADLoaded(List<NativeExpressADView> list) {
        Logger.d("ad --- > "+list.size());
        Logger.d("ad --- > "+list);
        NativeExpressADView nativeExpressADView = list.get(0);
        nativeExpressADView.render();
        adViewCallback.viewCallback(nativeExpressADView);
    }

    @Override
    public void onRenderFail(NativeExpressADView nativeExpressADView) {

    }

    @Override
    public void onRenderSuccess(NativeExpressADView nativeExpressADView) {

    }

    @Override
    public void onADExposure(NativeExpressADView nativeExpressADView) {

    }

    @Override
    public void onADClicked(NativeExpressADView nativeExpressADView) {

    }

    @Override
    public void onADClosed(NativeExpressADView nativeExpressADView) {

    }

    @Override
    public void onADLeftApplication(NativeExpressADView nativeExpressADView) {

    }

    @Override
    public void onADOpenOverlay(NativeExpressADView nativeExpressADView) {

    }

    @Override
    public void onADCloseOverlay(NativeExpressADView nativeExpressADView) {

    }

    @Override
    public void onNoAD(AdError adError) {

    }
}
